// require modules
const fs = require('fs');
const path = require('path')
const archiver = require('archiver');

// create a file to stream archive data to.
const output = fs.createWriteStream(__dirname + '/example.zip');
const archive = archiver('zip', {
  zlib: { level: 9 } // Sets the compression level.
});

archive.pipe(output);

// append files from a glob pattern
archive.glob('**/prod*/*.html', {
  cwd: path.resolve(__dirname)
}, function (data) {
  console.log(data);
});

// finalize the archive (ie we are done appending files but streams have to finish yet)
// 'close', 'end' or 'finish' may be fired right after calling this method so register to them beforehand
archive.finalize();
